<?php

namespace backend\controllers;

use bc\controller\BackendController;
use bc\model\MothersdayModel;
use bc\util\backend\Page;

class MothersdayController extends BackendController
{

	public function actionIndex()
	{
		$model = new MothersdayModel();
	
		$params = '1 = 1';
	
		$page = $this->get('page', 1);
		$model->sort = 'id DESC';
		$list = $model->getList($params, $page, self::PAGE_SIZE);
	
		$total = $model->getTotal($params);
	
		$pagination = new Page($total, self::PAGE_SIZE);
	
		$view['list'] = $list;
		$view['pagination'] = $pagination;
	
		return $this->render('index', $view);
	}
	
	public function actionEdit()
	{
		$id = $this->get('id');
		if(!$id)
			$this->redirect('/');
	
		$model = new MothersdayModel();
		$row = $model->getRowById($id);
	
		if(!$row)
			$this->redirect('/');
	
		$view['row'] = $row;
	
		return $this->render('edit', $view);
	}
}

